import React from 'react'
import ReactDOM from 'react-dom'

class Counter extends React.Component {
  state = {
    txt: ''
  }
  handleClick = (e) => {
    console.log(e.target.value)
    this.setState({

      txt: e.target.value
    })
  }
  render () {
    return (
      <div>
        <p>{this.state.txt}</p>
        <input value={this.state.txt} onChange={this.handleClick} />
        <button on onClick={() => {
          this.setState({
            txt: ''
          })
        }}>clear</button>
      </div>
    )
  }
}

ReactDOM.render(<Counter></Counter>, document.querySelector('#root'))